	<?php $this->load->view('admin/partials/payment_menu'); ?>
	<?php 
		$ci= &get_instance();
		 
		$fromDate = $this->input->get('fromDate',TRUE);
		$toDate = $this->input->get('toDate',TRUE);
		$username = $this->input->get('username',TRUE);
		if(!$fromDate){
			$fromDate = 'From Date';
		}
		
		if(!$toDate){
			$toDate = 'To Date';
		}
		
		if(!$username){
			$username = 'Username';
		}
		
		$userEmailArray = array();
		foreach($ci->user_entity->getArrayListOfUser() as $item){
			$userEmailArray[] = '"'.$item->username.'"'; 
		}
		
		$statusArray = codStatusDataConfig();
	?>
		
	<div class="clrboth"></div>
	<script type="text/javascript">
		var username = [<?php echo implode(',',$userEmailArray);?>];
	</script>
	
	<h3>COD Payment</h3>
	<div class="clrboth"></div>
	
	<?php $buttons = array('buttons'=>array('Completed Payment#view_completed_cod_payment();', 'Cancelled Payment#view_cancelled_cod_payment();') );?>
	<?php $this->load->view('admin/partials/buttons', $buttons ); ?>
	
	<div class="clrboth"></div>	
	<div style="float:left;clear:both;margin-top:15px;">
		<form id="mForm" accept-charset="utf-8" method="get" name="mForm" action="<?php echo site_url('admin/dataman/payment/cod');?>" >
			<input type="text" class="no-uniform" id="fromDate" name="fromDate" value="<?php echo $fromDate;?>" />				
			<input type="text" class="no-uniform" id="toDate" name="toDate" value="<?php echo $toDate;?>" />	
			<input type="text" class="no-uniform" id="username" name="username" value="<?php echo $username;?>" />		
			<input type="submit" value="Search" class="no-uniform" />	
		</form>	
	</div>
	<div class="clrboth"></div>
	<br/>
	<table border="0" class="table-list">
		<thead>
			<tr> 	 	 	 	
				<th>Package</th>
				<th>Amount (INR)</th>
				<th>Coin</th>
				<th>Code</th>
				<th>User</th>
				<th>Date/Time</th>
				<th>Manage</th>	
			</tr>
		</thead>
		
		<tbody>
			<?php foreach( $items['records'] as $item ): ?>
			<?php 
				$PACKAGE = $ci->coin_packages_entity->init('id',$item->package_id);
				$USER = $ci->user_entity->init('id',$item->user_id);
			?>
			<tr>
				<td><?php echo $PACKAGE->getPackage(); ?></td>
				<td><?php echo format_Money($item->price,true); ?></td>
				<td><?php echo $item->coin; ?></td>
				<td>&nbsp;
					<?php if($item->status == 'approved' || $item->status == 'dispatched'):?>
						<?php echo $item->code;?>
					<?php endif; ?>
				</td>
				<td><?php echo $USER->getUserName(); ?></td>
				<td><?php echo sysDateTimeFormat($item->created_time , DATE_FM); ?></td>
				<td>
					<?php if($item->status == 'pending'):?>
						<a href="javascript:void(0);" onclick="approve_cod_item(<?php echo $item->id;?>);" >Approve</a>
						&nbsp;|&nbsp;
						<a href="javascript:void(0);" onclick="cancel_cod_item(<?php echo $item->id;?>);" >Cancel</a>
						&nbsp;|&nbsp;
					<?php endif; ?>
					
					<?php if($item->status == 'approved'):?>
						<a href="javascript:void(0);" onclick="dispatch_cod_item(<?php echo $item->id;?>);" >Dispatch</a>
						&nbsp;|&nbsp;
						<a href="javascript:void(0);" onclick="cancel_cod_item(<?php echo $item->id;?>);" >Cancel</a>
						&nbsp;|&nbsp;
					<?php endif; ?>
					
					<a href="<?php echo site_url("admin/dataman/payment/print/").'/?id='.$item->id;?>" class="print">Print</a>
					<?php echo loader_image("id=\"loader_image_{$item->id}\" class=\"hidden\"");?>
				</td>
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
	<div class="inner"><?php echo $items['pagination']['links'];?></div>

<script type="text/javascript">
	
	jQuery(document).ready(function() {
		jQuery('.print').popupWindow({ 
			height:800, 
			width:900, 
			top:10, 
			left:10 
		}); 
		
	})
</script>  